<template>
  <div class="student">
    <h1>学校名称：{{ name }}</h1>
    <h1>学校地址：{{ address }}</h1>
    <button @click="sendData">把学校名称给App</button>
  </div>
</template>

<script>

export default {
  name: "Student",

  data() {
    return {
      name: "陶品奇",
      address: "衡阳"
    }
  },
  props: ["getAddressData"],
  methods: {
    sendData() {
      this.$emit("getNameData", this.name)
      this.getAddressData(this.address)
    }
  },
  beforeDestroy() {
    /*this.$off("getNameData")//解绑一个自定义事件
    this.$off(["事件名称", "事件名称"])//解绑多个自定义事件
    this.$off()//解绑所有自定义事件*/
  }
};
</script>

<style>
.student {
  background-color: #DC143C;
}
</style>
